package com.example.farmeri.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.farmeri.R;
import com.example.farmeri.data.config.DataConfig;

import java.util.List;

/**
 * Create by weiqishan on 2020/4/12.
 */
public class MineFragmentAdapter extends RecyclerView.Adapter {

    Context context;
    Integer layout;

    List<Object> dataList;

    public MineFragmentAdapter(Context context, int layout) {
        this.context = context;
        this.layout = layout;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
        View itemView = inflater.inflate(layout,viewGroup,false);
        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
        MyViewHolder myViewHolder = (MyViewHolder) viewHolder;
//        myViewHolder.imageView.setImageResource(DataConfig.mine_img[i%DataConfig.mine_img.length]);
//        myViewHolder.textView.setText(DataConfig.mine_title[i%DataConfig.mine_title.length]);
    }

    @Override
    public int getItemCount() {
        if (dataList==null) return 20;
        return dataList.size();
    }


    private class MyViewHolder extends RecyclerView.ViewHolder {

        ImageView imageView;
        TextView textView;


        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView = itemView.findViewById(R.id.item_mine_image);
            textView = itemView.findViewById(R.id.item_mine_text);
        }
    }
}
